import {View} from '@tarojs/components'
import './index.scss'

interface TableProps {
    type?: 'A' | 'B',
    itemWidth: string[],
    itemClass?: string[],
    tableTitle: string[],
    dataList: any[],
    className?: string[],
    style?: object,
}
export default function LgTable(props: TableProps) {
    var itemWidth = props.itemWidth,
        dataList = props.dataList,
        itemClass = props.itemClass || [],
        className = props.className || "";
    if (props.type) className = `props.className lg_table_type${props.type}`
    return (
        <View className={`lg_table_warp ${className}`} style={props.style || {}}>
            <View className="lg_table_top clear">
                {
                    props.tableTitle.map(function(o, i) {
                        return <View className='left' key={"h_table_i" + i} style={{ width: itemWidth[i] }}>{o}</View>
                    })
                }
            </View>
            <View className="lg_table_list_warp">
                {
                    dataList.map(function (o, i) {
                        return (
                            <View className="lg_table_line clear" key={"h_table_list" + i}>
                                {
                                    o.map(function(obj, j) {
                                        return <View style={{width: itemWidth[j]}} className={`lg_table_item ${itemClass[i] || ''}`} key={"h_table_list_i" + j}>{obj}</View>
                                    })
                                }
                            </View>
                        )
                    })
                }
            </View>
        </View>
    )
}